import request from "@/utils/request";

// 查询定位器列表
export function listLocator(query) {
  return request({
    url: "/pack/locator/list",
    method: "get",
    params: query,
  });
}

// 查询定位器详细
export function getLocator(locatorId) {
  return request({
    url: "/pack/locator/" + locatorId,
    method: "get",
  });
}

// 新增定位器
export function addLocator(data) {
  return request({
    url: "/pack/locator",
    method: "post",
    data: data,
  });
}

// 修改定位器
export function updateLocator(locatorId, data) {
  return request({
    url: "/pack/locator/" + locatorId,
    method: "put",
    data: data,
  });
}

// 删除定位器
export function delLocator(locatorId) {
  return request({
    url: "/pack/locator/" + locatorId,
    method: "delete",
  });
}

// 更新定位器状态
export function updateLocatorStatus(locatorId, data) {
  return request({
    url: "/pack/locator/" + locatorId + "/status",
    method: "put",
    data: data,
  });
}

// 查询未绑定器具的定位器
export function getUnboundLocators() {
  return request({
    url: "/pack/locator/unbound",
    method: "get",
  });
}

// 查询已绑定器具的定位器
export function getBoundLocators() {
  return request({
    url: "/pack/locator/bound",
    method: "get",
  });
}

// 获取定位器选项列表
export function getLocatorOptions() {
  return request({
    url: "/pack/locator/options",
    method: "get",
  });
}

// 根据编码查询定位器
export function getLocatorByCode(locatorCode) {
  return request({
    url: "/pack/locator/code/" + locatorCode,
    method: "get",
  });
}

// 检查定位器编码唯一性
export function checkLocatorCode(locatorCode) {
  return request({
    url: "/pack/locator/checkLocatorCodeUnique",
    method: "get",
    params: { locatorCode },
  });
}

// 导出定位器
export function exportLocator(query) {
  return request({
    url: "/pack/locator/export",
    method: "post",
    params: query,
  });
}

// 下载定位器导入模板
export function importTemplate() {
  return request({
    url: "/pack/locator/importTemplate",
    method: "post",
  });
}

// 解绑运单
export function unbindShipment(locatorIds) {
  return request({
    url: "/pack/locator/unbind-shipment",
    method: "put",
    data: { locatorIds: locatorIds },
  });
}

// 查询定位日志列表
export function getLocationLogs(query) {
  return request({
    url: "/pack/location/log/list",
    method: "get",
    params: query,
  });
}
